package com.mls.fivedistrict.controller.portal;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mls.fivedistrict.common.PageFilter;
import com.mls.fivedistrict.common.RequestHolder;
import com.mls.fivedistrict.common.ServiceResponse;
import com.mls.fivedistrict.controller.BaseController;
import com.mls.fivedistrict.pojo.NewsClassify;
import com.mls.fivedistrict.server.NewsClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by chenxiuxiang on 2018/6/28.
 */

@RestController(value = "portalNewsClassifyController")
@RequestMapping("/api/app")
public class NewsClassifyController extends BaseController {

    @Autowired
    NewsClassifyService newsClassifyService;


    @GetMapping("/v1/newsClassify")
    public ServiceResponse getNewsClassifyList() {
        PageFilter pageFilter = RequestHolder.getPageFilter();
        PageHelper.startPage(pageFilter.getPageNum(), pageFilter.getPageSize());
        List list = newsClassifyService.selectList(pageFilter.getWrapper());
        PageInfo<NewsClassify> pageInfo = new PageInfo<>(list, 5);
        return ServiceResponse.createSuccessResponse(pageInfo);
    }
}
